﻿// Copyright (c) Vitaly Kamiansky. All rights reserved. 
// See License.txt in the project root.

using System;
using System.Reactive.Disposables;
using System.Reactive.Linq;

namespace Property.Sequences
{
    public class SourceSequenceConveyor<T> : SequenceConveyor<T>
    {
        public SourceSequenceConveyor(Func<Func<T>, IObservable<T>> getSequence)
        {
            if (getSequence == null) throw new ArgumentNullException("getSequence");

            _GetSequence = o => o == null ? null : getSequence(o);
        }

        //=//

        private readonly Func<Func<T>, IObservable<T>> _GetSequence;

        public override IObservable<T> Create(Func<T> getValue)
        {
            return _GetSequence(getValue);
        }
    }
}
